﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Might.Infrastructure.Services;

namespace Might.UIControls.StatusBar {
    public partial class StatusBarView : IStatusBarView {
        private StatusBarViewItem lastItem;

        public StatusBarView() {
            InitializeComponent();
        }

        public string UserName {
            get { return UserNameTxt.Text; }
            set { UserNameTxt.Text = value; }
        }

        public void AddProgress(IProgressToken token) {
            var item = new StatusBarViewItem(this);
            if (lastItem != null) {
                ProgressStack.Children.Remove(lastItem);
                lastItem = null;
            }
            ProgressStack.Children.Add(item);
            item.Activate(token);
        }

        public void RemoveItem(StatusBarViewItem item) {
            // TODO support for multiple active items
            lastItem = item;
        }
    }
}
